// Get continuum transfunctioner automatically, originally by Alhifar
// Modified and MUCH added by Bale
script "Woods Override"
notify "Bale";

boolean no_legionknife() {
	if(in_hardcore()) return false;
	foreach it in get_related($item[Loathing Legion knife], "fold")
		if(available_amount(it) > 0 || storage_amount(it) > 0) return false;
	return true;
}

string mystic() {
	string text() {
		if(my_path() == "Zombie Slayer")
			return 'The Crackpot Mystic says, "Urrrgh," pulling a round object from his pocket and rolling it across the floor at you. "Graaaaaaagh."';
		return "You stop off at the Crackpot Mystic's Shed and listen to a long boring story.";
	}
	return '<div style="color:#0000CC;">'+text()+'</div>'+
	  "<center><table style='color:#0000CC;'><tr><td><img src='/images/itemimages/transfunc.gif'></td><td><b>You acquire an item: continuum transfunctioner</b></td></tr></table></center></p><p>";
}

string untinker() {
	string text1() {
		if(my_path() == "Zombie Slayer")
			return '"Ssscrruuuuuudruuuhh. Gnaaaaah. Duhgaaah gnaaaaah," says the Untinker. "Okay," you reply, "I\'ll go find your screwdriver for you."';
		return "The untinker needs you to run some errands.";
	}
	string text2() {
		if(my_path() == "Zombie Slayer")
			return '"Aaaarrrrrrgh!" the Untinker howls as you give him his screwdriver back. He shambles around the cottage, waving it in the air happily. "Graaaaagh!"';
		return "After returning the screwdriver to the untinker he swears eternal servitude!";
	}
	return '<div style="color:#0000CC;">'+text1()+'</div>'+
	  "<center><table style='color:#0000CC;'><tr><td><img src='/images/itemimages/screwdrive.gif'></td><td><b>You acquire an item: rusty screwdriver</b></td>"+
	  "<td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td>"+
	  "<td><img src='/images/itemimages/screwdrive.gif'></td><td><b>You lose an item: rusty screwdriver</b></td></tr></table></center>"+
	  '<div style="color:#0000CC;">'+text2()+'</div></p><p>';
}

void main() {
	if(form_field("action") != "") exit; 
	buffer crack = visit_url("woods.php");
	if(available_amount($item[continuum transfunctioner]) == 0) {
		#visit_url("mystic.php?action=crackyes3&crack1=Er%2C+sure%2C+I+guess+so...&pwd");
		visit_url("forestvillage.php?action=mystic");
		visit_url("choice.php?pwd="+my_hash()+"&whichchoice=664&option=1&choiceform1=Sure%2C+old+man.++Tell+me+all+about+it.");
		visit_url("choice.php?pwd="+my_hash()+"&whichchoice=664&option=1&choiceform1=Against+my+better+judgment%2C+yes.");
		visit_url("choice.php?pwd="+my_hash()+"&whichchoice=664&option=1&choiceform1=Er,+sure,+I+guess+so...");
		crack.insert(crack.index_of("<center><a href=\"main.php\">"), mystic());
		if(no_legionknife() || knoll_available()) {
			visit_url("forestvillage.php?action=screwquest");
			if(!knoll_available())
				crack.insert(crack.index_of("<center><a href=\"main.php\">"), 
				  "<div style='color:#0000CC;'>The untinker needs you to run some errands.</p><p>");
		}
		if(knoll_available()) {
			visit_url("knoll.php?place=smith");
			visit_url("forestvillage.php?place=untinker");
			crack.insert(crack.index_of("<center><a href=\"main.php\">"), untinker());
		}
	}
	crack.write();
}